@extends('admin.layouts.layout')
@section('content')
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-title">
                <h5>添加充值</h5>
            </div>
            <div class="ibox-content">
                <a class="menuid btn btn-primary btn-sm m-b-sm" href="{{getBackUrl()}}">返回</a>
                <form id="myForm" class="form-horizontal" action="{{route('recharge.store')}}" method="post"
                      enctype="multipart/form-data">
                    {!! csrf_field() !!}
                    <input type="hidden" name="goBackUrl" value="{{getBackUrl()}}"/>
                    <table class="table-striped table-bordered table-hover table-condensed">
                        <tr class="b-group">
                            <th style="min-width: 108px;">
                                <label>渠道</label>
                            </th>
                            <td class="b-child">
                                <div style="max-height:6.5rem;overflow-y:scroll;">
                                    @include('widget.channel_radio')
                                </div>
                            </td>
                        </tr>
                        <tr class="b-group">
                            <th width="10%">
                                <label>服务器</label>
                            </th>
                            <td class="b-child">
                                <div style="max-height:10rem;overflow-y:scroll;">
                                    @include('widget.server_radio')
                                </div>
                            </td>
                        </tr>
                        <tr class="b-group">
                            <th width="10%">
                                <label>玩家昵称</label>
                            </th>
                            <td class="b-child">
                                <table class="table-striped table-bordered table-hover table-condensed col-xs-12"
                                       style="margin: 0px;">
                                    <tr class="b-group">
                                        <td id="tdChannels">
                                            <input class="pull-left col-xs-12" type="text" name="nickname"
                                                   value="{{old('nickname','')}}"
                                                   placeholder="请输入玩家昵称" maxlength="200" autocomplete="off">
                                        </td>
                                        <?php
                                        if ($errors->has('nickname')) {
                                            echo "<td><span class=\"help-block m-t-none\"><i class=\"fa fa-info-circle\"></i><code>{$errors->first('nickname')}</code></span></td>";
                                        }
                                        ?>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr class="b-group">
                            <th width="10%">
                                <label>发放理由</label>
                            </th>
                            <td class="b-child">
                                <table class="table-striped table-bordered table-hover table-condensed col-xs-12"
                                       style="margin: 0px;">
                                    <tr class="b-group">
                                        <td id="tdChannels">
                                            <input class="pull-left col-xs-12" type="text" name="reason"
                                                   value="{{old('reason','')}}"
                                                   placeholder="请输入发放理由" maxlength="200" autocomplete="off">
                                        </td>
                                        <?php
                                        if ($errors->has('reason')) {
                                            echo "<td><span class=\"help-block m-t-none\"><i class=\"fa fa-info-circle\"></i><code>{$errors->first('reason')}</code></span></td>";
                                        }
                                        ?>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr class="b-group">
                            <th width="10%">
                                <label>充值物品</label>
                            </th>
                            <td class="b-child">
                                <table class="table-striped table-bordered table-hover table-condensed col-xs-12"
                                       style="margin: 0px;">
                                    <tr class="b-group">
                                        <td class="form-inline">
                                            <select data-placeholder="选择物品" class="chosen-select" name="item_id">
                                                <option value="">选择物品</option>
                                                <?php
                                                $items_html = '';
                                                $selected = '';
                                                foreach ($items as $itemId => $itemName) {


                                                    if ($itemId === old('item_id')) {
                                                        $selected = 'selected';
                                                    } else {
                                                        $selected = '';
                                                    }

                                                    $items_html .= "<option value=\"{$itemId}\" hassubinfo=\"true\" {$selected}>{$itemName}({$itemId})</option>";
                                                }

                                                echo $items_html;
                                                ?>
                                            </select>
                                        </td>
                                        <?php
                                        if ($errors->has('item_id')) {
                                            echo "<td><span class=\"help-block m-t-none\"><i class=\"fa fa-info-circle\"></i><code>{$errors->first('item_id')}</code></span></td>";
                                        }
                                        ?>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr class="b-group">
                            <th width="10%">
                            </th>
                            <td class="b-child">
                                @include('widget.query_and_refresh',['submit_button_name'=>'提 交'])
                            </td>
                        </tr>
                    </table>
                    <input type="hidden" id="hidItemName" value="" name="item_name"/>
                </form>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
    <script>
    </script>
    <link href="{{loadEdition('/admin/css/plugins/datapicker/bootstrap-datepicker.css')}}" rel="stylesheet">
    <link href="{{loadEdition('/admin/js/plugins/bootstrap-table/bootstrap-table.min.css')}}" rel="stylesheet">
    <link href="{{loadEdition('/js/plugins/chosen_v1.8.7/chosen.min.css')}}" rel="stylesheet">

@endsection
@section('js')
    <!--bootstrap-datepicker start-->
    <script src="{{loadEdition('/admin/js/plugins/datapicker/bootstrap-datepicker.js')}}"></script>
    <script src="{{loadEdition('/admin/js/plugins/datapicker/bootstrap-datepicker.zh-CN.js')}}"></script>
    <!--bootstrap-datepicker end-->
    <!--bootstrap-table start-->
    <script src="{{loadEdition('/admin/js/plugins/bootstrap-table/bootstrap-table.min.js')}}"></script>
    <script src="{{loadEdition('/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.js')}}"></script>
    <!--bootstrap-table end-->
    <!--chosen-->
    <script src="{{loadEdition('/js/plugins/chosen_v1.8.7/chosen.jquery.min.js')}}"></script>
    <script src="{{loadEdition('/js/plugins/chosen_v1.8.7/chosen.proto.min.js')}}"></script>
    <script src="{{loadEdition('/js/global.js')}}"></script>
    <script>
        $(document).ready(function () {

            //把附件名称放入input:hidden
            $('#myForm').submit(function () {
                var item_name = '';
                $('.chosen-single span').each(function (index, element) {
                    item_name = element.innerHTML;
                })

                $('#hidItemName').val(item_name);

                return true;
            });

        });
    </script>
@stop